<template>
  <van-tabbar v-model="active" route>
    <van-tabbar-item v-for="(item,index) in list" :key="index" :to="(item.name)">
      <span>{{item.title}}</span>
      <img slot="icon" slot-scope="props" :src="props.active ? item.active : item.normal" />
    </van-tabbar-item>
  </van-tabbar>
</template>
<script>
export default {
  name: "Tabbar",
  data() {
    return {
      active: 0,
      list: [
        {
          name: "/Index",
          title: "记账",
          normal:
            // "http://sucai.suoluomei.cn/sucai_zs/images/20190910093117-fx2.png",
            require("../../assets/image/1.png"),
          active:
            // "http://sucai.suoluomei.cn/sucai_zs/images/20190910093117-fx.png"
            require("../../assets/image/1.png")
        },
        {
          name: "/Query",
          title: "查询",
          normal:
            // "http://sucai.suoluomei.cn/sucai_zs/images/20190910093117-xx.png",
            require("../../assets/image/2.png"),
          active:
            // "http://sucai.suoluomei.cn/sucai_zs/images/20190910093117-xx2.png"
            require("../../assets/image/2.png")
        },
        {
          name: "/Personal",
          title: "我的",
          normal: require("../../assets/image/4.png"),
          // "http://sucai.suoluomei.cn/sucai_zs/images/20190910093117-wd.png",
          active: require("../../assets/image/4.png")

          // "http://sucai.suoluomei.cn/sucai_zs/images/20190910093117-wd2.png"
        }
      ]
    };
  },
  // methods: {
  //   change() {
  //     if (this.active === 0) {
  //       this.$router.push("/Index");
  //     } else if (this.active === 1) {
  //       this.$router.push("/Query");
  //     }else if(this.active === 2){
  //       this.$router.push("/Personal")
  //     }
  //   }
  // },
  created() {
    if (this.$route.name == "index") {
      this.active = 0;
    } else if (this.$router.name == "Query") {
      this.active = 1;
    } else if (this.$router.name == "Personal") {
      this.active = 2;
    }
  }
};
</script>

<style>
.tabbar1 {
  display: flex;
  flex-direction: column;
  align-items: center;
}
</style>
